feat(sdk-core): getMpcV2RetrofitDataFromMpcV1Keys for EdDSA - #9461
Open
bitgo-ai-agent-dev[bot] wants to merge 2 commits into
Open
feat(sdk-core): getMpcV2RetrofitDataFromMpcV1Keys for EdDSA#9461bitgo-ai-agent-dev[bot] wants to merge 2 commits into
bitgo-ai-agent-dev[bot] wants to merge 2 commits into
Conversation
Add `getMpcV2RetrofitDataFromMpcV1Keys` (public instance method) and a private static helper `getMpcV2RetrofitDataFromMpcV1Key` on `EddsaMPCv2Utils`. Also introduce the `EddsaRetrofitData` type and export it from the package root. The methods convert MPCv1 EdDSA key shares (JSON with uShare.seed and uShare.chaincode) into `EddsaRetrofitData` objects that can be passed to `new EddsaMPSDkg.DKG(…, retrofitData)` to seed a retrofit DKG ceremony. Scalar derivation follows RFC 8032 Ed25519 key expansion: scalar = clamp(SHA512(seed_bytes)[0:32]) where clamping clears bits 0-2 of byte[0], clears bit 7 of byte[31], and sets bit 6 of byte[31]. The aggregate public key (expectedPk) is read from the user key's pShare.y and reused for both parties, since both parties share the same root public key in the MPCv1 scheme. Required by WCI-1264 (getUserAndBackupSession + createKeychains retrofit wiring) to derive the retrofit data before starting the DKG ceremony. Ticket: WCI-1263 Session-Id: 9430179b-3b09-4c4c-9c75-723c484f16b5 Task-Id: 29bdbf4d-6e4f-4646-bd79-06a89e5dcf28
Contributor
ralph-bitgo
Bot
force-pushed
the
WCI-1263-getMpcV2RetrofitDataFromMpcV1Key-EdDSA
branch
from
August 10, 2026 16:18
decc117 to
38ea35e
Compare
bitgo-ai-agent-dev
Bot
force-pushed
the
WCI-1263-getMpcV2RetrofitDataFromMpcV1Key-EdDSA
branch
from
August 10, 2026 16:18
38ea35e to
4dfa8d0
Compare
Marzooqa
force-pushed
the
WCI-1263-getMpcV2RetrofitDataFromMpcV1Key-EdDSA
branch
2 times, most recently
from
August 11, 2026 12:26
18b0093 to
62d3e34
Compare
Replaces the hand-rolled scalar derivation (manual SHA-512 + clamp with a zeroize try/finally, and reading a non-existent `pShare` field off the raw decrypted keycard JSON) with a call to `MPC.keyCombine(uShare, yShares)` — the same combine step every other MPCv1 EdDSA code path already uses. The decrypted MPCv1 key share (`SigningMaterial`) only ever contains `uShare` + `bitgoYShare` + `backupYShare`/`userYShare`; it has no `pShare`, and `uShare.chaincode` is only one party's additive contribution to the real BIP32 chain code, not the combined value. Deriving `s_i_0`/`expectedPk`/`chainCode` from the real `pShare.u`/`pShare.y`/`pShare.chaincode` output of keyCombine fixes both issues at once and asserts user/backup agree on the aggregate public key and chain code before returning. Structures the per-party helper like ecdsaMPCv2.ts's getMpcV2RetrofitDataFromMpcV1Key: it takes the raw JSON key-share string and an MPCv2PartiesEnum.USER/BACKUP index, JSON.parses and switches on the index internally, and asserts every share it's about to feed into keyCombine (uShare, bitgoYShare, and the counterparty YShare) right where they're used — mirroring ECDSA's assertion style since JSON.parse returns unchecked data and the SigningMaterial type's non-optional fields aren't a runtime guarantee. Moves `EddsaRetrofitData` into `@bitgo/sdk-lib-mpc`'s `tss/eddsa-mps/types.ts` (as `MPSTypes.EddsaRetrofitData`), mirroring where DKLS keeps its `RetrofitData` type, instead of defining and re-exporting it from sdk-core. Rewrites tests to exercise real 3-party MPCv1 key shares generated via `Eddsa.keyShare`/`keyCombine` instead of hand-built JSON fixtures with a `pShare` field that never occurs in production data, and covers each assertion branch. Ticket: WCI-1263
Marzooqa
force-pushed
the
WCI-1263-getMpcV2RetrofitDataFromMpcV1Key-EdDSA
branch
from
August 11, 2026 13:09
62d3e34 to
9957029
Compare
Contributor
Contributor
|
Claude finished @Marzooqa's task —— View job Code Review Complete ✅Reviewing the EdDSA MPCv2 retrofit implementation for WCI-1263. Todo List:
Review SummaryThis PR successfully implements EdDSA MPCv2 retrofit functionality for migrating from MPCv1 to MPCv2 keys. The implementation is solid and addresses the requirements well. Key Strengths1. Correct Architectural Approach
2. Type Safety & Location
3. Robust Input Validation
4. Excellent Test Coverage
5. Security Considerations
Implementation DetailsPublic Interface (
|
Marzooqa
marked this pull request as ready for review
August 11, 2026 15:00
Marzooqa
requested review from
pranavjain97,
pranishnepal and
rishikeshdadam136
August 11, 2026 15:00
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Why
Required by WCI-1264 (getUserAndBackupSession + createKeychains retrofit wiring). The retrofit DKG ceremony (ed25519_dkg_round0_import) needs EddsaRetrofitData seeded from the user's existing MPCv1 keys before the ceremony begins. MPCv1 stores a 32-byte seed rather than the scalar directly; this method performs the RFC 8032 key expansion so both user and backup parties can seed their DKG sessions from their existing KeyCard material, enabling in-place migration from MPCv1 to MPCv2 without re-keying.
Test plan
Ticket: WCI-1263